import React, { Component } from 'react';
import { Button } from 'antd';
import { 
	DownloadOutlined,
	DeleteOutlined,
	RotateRightOutlined,
	LinkOutlined,
	TeamOutlined
} from '@ant-design/icons';
import { connect } from 'react-redux';
import './index.less';

class Buttons extends Component {
	
	handleClick = (type) => {
		//使用redux：文件的各项操作，在其它页面能监听数据变化，
		this.props.fileAction(type);
	}
	
	render(){
		return (
			<div className="upload-btn buttons">
				<Button type="primary" ghost onClick={()=>this.handleClick("download")} icon={<DownloadOutlined />} >下载</Button>
				<Button type="primary" ghost onClick={()=>this.handleClick("delete")} icon={<DeleteOutlined />} >删除</Button>
				<Button type="primary" ghost onClick={()=>this.handleClick("move")} icon={<RotateRightOutlined />} >移动到</Button>
				<Button type="primary" ghost onClick={()=>this.handleClick("share")} icon={<LinkOutlined />} >分享</Button>
				<Button type="primary" ghost onClick={()=>this.handleClick("sharegroup")} icon={<TeamOutlined />} >加入共享组</Button>
			</div>
		)
	}
}

const mapDispatch = (dispatch) => {
	return {
		fileAction(type){
			dispatch({
				type: "FILE_ACTION",
				fileAction: type
			})
		}
	}
}

export default connect(null, mapDispatch)(Buttons);